package com.edu.edu.day9_19_week7_homework.thread;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.widget.ImageView;

/**
 * Created by Administrator on 9/19 0019.
 */
public class LoadImageTask extends AsyncTask<String,Void,Bitmap>{

    private ImageView mLogo;
    public  LoadImageTask(ImageView logo){
        this.mLogo = logo;
    }

    @Override
    protected Bitmap doInBackground(String... params) {
        byte[] data = HttpUtil.loadData(params[0]);
        return BitmapFactory.decodeByteArray(data,0,data.length);
    }

    @Override
    protected void onPostExecute(Bitmap bitmap) {
        super.onPostExecute(bitmap);
        if(bitmap != null){
            mLogo.setImageBitmap(bitmap);
        }
    }
}
